package com.rickpan.dto.contacts;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.rickpan.entity.UserPrivacySettings;

import java.time.LocalDateTime;

/**
 * 隐私设置响应DTO
 */
public class PrivacySettingsResponse {

    private Long id;
    private Long userId;
    private Boolean allowSearchByUsername;
    private Boolean allowSearchByEmail;
    private Boolean allowSearchByRealName;
    private Boolean showOnlineStatus;
    private Boolean allowFriendRequests;
    private Boolean autoAcceptTeamMembers;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedAt;

    // 构造函数
    public PrivacySettingsResponse() {}

    public PrivacySettingsResponse(UserPrivacySettings settings) {
        this.id = settings.getId();
        this.userId = settings.getUserId();
        this.allowSearchByUsername = settings.getAllowSearchByUsername();
        this.allowSearchByEmail = settings.getAllowSearchByEmail();
        this.allowSearchByRealName = settings.getAllowSearchByRealName();
        this.showOnlineStatus = settings.getShowOnlineStatus();
        this.allowFriendRequests = settings.getAllowFriendRequests();
        this.autoAcceptTeamMembers = settings.getAutoAcceptTeamMembers();
        this.createdAt = settings.getCreatedAt();
        this.updatedAt = settings.getUpdatedAt();
    }

    // 静态工厂方法
    public static PrivacySettingsResponse from(UserPrivacySettings settings) {
        return new PrivacySettingsResponse(settings);
    }

    // Getter和Setter方法
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Boolean getAllowSearchByUsername() {
        return allowSearchByUsername;
    }

    public void setAllowSearchByUsername(Boolean allowSearchByUsername) {
        this.allowSearchByUsername = allowSearchByUsername;
    }

    public Boolean getAllowSearchByEmail() {
        return allowSearchByEmail;
    }

    public void setAllowSearchByEmail(Boolean allowSearchByEmail) {
        this.allowSearchByEmail = allowSearchByEmail;
    }

    public Boolean getAllowSearchByRealName() {
        return allowSearchByRealName;
    }

    public void setAllowSearchByRealName(Boolean allowSearchByRealName) {
        this.allowSearchByRealName = allowSearchByRealName;
    }

    public Boolean getShowOnlineStatus() {
        return showOnlineStatus;
    }

    public void setShowOnlineStatus(Boolean showOnlineStatus) {
        this.showOnlineStatus = showOnlineStatus;
    }

    public Boolean getAllowFriendRequests() {
        return allowFriendRequests;
    }

    public void setAllowFriendRequests(Boolean allowFriendRequests) {
        this.allowFriendRequests = allowFriendRequests;
    }

    public Boolean getAutoAcceptTeamMembers() {
        return autoAcceptTeamMembers;
    }

    public void setAutoAcceptTeamMembers(Boolean autoAcceptTeamMembers) {
        this.autoAcceptTeamMembers = autoAcceptTeamMembers;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    @Override
    public String toString() {
        return "PrivacySettingsResponse{" +
                "id=" + id +
                ", userId=" + userId +
                ", allowSearchByUsername=" + allowSearchByUsername +
                ", allowSearchByEmail=" + allowSearchByEmail +
                ", allowSearchByRealName=" + allowSearchByRealName +
                ", showOnlineStatus=" + showOnlineStatus +
                ", allowFriendRequests=" + allowFriendRequests +
                ", autoAcceptTeamMembers=" + autoAcceptTeamMembers +
                ", createdAt=" + createdAt +
                ", updatedAt=" + updatedAt +
                '}';
    }
}
